<template>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        供应商管理
        <small>管理您的供应商</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-globe"></i> 供应商管理</a></li>
        <li class="active">添加供应商</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">添加供应商</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <form role="form">
                <!-- text input -->
                <div class="form-group">
                  <label for="vendorsName">供应商名称</label>
                  <input class="form-control" placeholder="请输入供应商名称" type="text" id="vendorsName">
                </div>
                <div class="form-group">
                  <label for="vendorsLocation">供应商地址</label>
                  <input class="form-control" placeholder="请输入供应商地址" type="text" id="vendorsLocation">
                </div>
                <div class="form-group">
                  <label for="vendorsContact">供应商联系方式</label>
                  <input class="form-control" placeholder="请输入供应商联系方式" type="number" id="vendorsContact">
                </div>
                <div>
                  <p class="alert alert-danger hidden" id="message">message</p>
                </div>
              </form>
            </div>
            <div class="box-footer">
              <button @click="add" class="btn btn-primary">点击提交</button>
            </div>
            <!-- /.box-body -->
          </div>
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
</template>

<script>
export default {
  name: "AddVendors",
  methods:{
    add(){
      var vendorsName = document.getElementById("vendorsName");
      var vendorsLocation = document.getElementById("vendorsLocation");
      var vendorsContact = document.getElementById("vendorsContact");
      this.GLOBAL.appData.vendorsList.push({
        "id":this.GLOBAL.appData.vendorsList[this.GLOBAL.appData.vendorsList.length-1].id+1,
        "name":vendorsName.value,
        "location":vendorsLocation.value,
        "contact":vendorsContact.value
      });
      this.$message.info("成功添加（模拟操作）");
      this.$router.push("/main/vendorsData")
    }
  },
  mounted() {
    $(document).ready(function () {
      // 选择框
      $(".select2").select2();

      // WYSIHTML5编辑器
      $(".textarea").wysihtml5({
        locale: 'zh-CN'
      });
    });

    $(function () {
      $("#example1").DataTable();
      $('#example2').DataTable({
        "paging": true,
        "lengthChange": false,
        "searching": false,
        "ordering": true,
        "info": true,
        "autoWidth": false
      });
    });
  }
}
</script>

<style scoped>

</style>
